package com.junxian.demo02;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

/*
* Spring Boot和Feign中使用Java 8时间日期API（LocalDate等）的序列化问题。
* */
@SpringBootApplication
public class Demo02Application {

	public static void main(String[] args) {
		SpringApplication.run(Demo02Application.class, args);
	}

	@Configuration
	class MessageConverterConfig extends WebMvcConfigurerAdapter{
		@Override //重写的方法必须是它本身原来的方法
		public void configureMessageConverters(List<HttpMessageConverter<?>> converters){
			Jackson2ObjectMapperBuilder builder =Jackson2ObjectMapperBuilder.xml();
			builder.indentOutput(true);
			converters.add(new MappingJackson2XmlHttpMessageConverter());
		}
	}

}
